import request from '@/utils/request'

// 文章-获取文章列表
export const articlesListAPI = ({ channelId, timestamp }) => {
  return request({
    url: '/v1_0/articles',
    params: {
      channel_id: channelId,
      timestamp: timestamp || new Date().getTime() + '' // 如果第一次无timestamp,就使用系统时间字符串
    }
  })
}

// 文章-删除文章列表
export const disLikesAPI = ({ target }) => {
  return request({
    url: '/v1_0/article/dislikes',
    method: 'POST',
    data: {
      target: target
    }
  })
}
// 文章-举报
export const reportsAPI = ({ target, type }) => {
  return request({
    url: '/v1_0/article/reports',
    method: 'POST',
    data: {
      target: target,
      type: type,
      remark: type === 0 ? '其他问题' : null
    }
  })
}

// 文章-文章详情
export const articleInfoAPI = ({ id }) => {
  return request({
    url: `/v1_0/articles/${id}`
  })
}

// 文章-关注作者
export const followingAPI = ({ target }) => {
  return request({
    url: '/v1_0/user/followings',
    method: 'POST',
    data: {
      target
    }
  })
}
// 文章-取消关注作者
export const unfollowingAPI = ({ id }) => {
  return request({
    url: `/v1_0/user/followings/${id}`,
    method: 'DELETE'
  })
}
// 文章-喜欢
export const likingsAPI = ({ target }) => {
  return request({
    url: '/v1_0/article/likings',
    method: 'POST',
    data: {
      target
    }
  })
}
// 文章-取消喜欢
export const unLikingsAPI = ({ id }) => {
  return request({
    url: `/v1_0/article/likings/${id}`,
    method: 'DELETE'
  })
}
